%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% File:               representatives_game_LS.m
%
% Author:             Miguel R. Rueda
%
% Description:        Least squares estimator. 
%
% Language:           MATLAB R2013b (8.2.0.701) 64 Bit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function betas=representatives_game_LS(Y,X,state,CLv_PAN,CLv_PRI,beta_p)

%Initial guess
if state==1
    [phats,~]=first_stage(Y,X,CLv_PAN,CLv_PRI);
else
    [phats,~]=first_stage(Y,X);
end
     
%Second stage results
if nargin<6
    beta=Paramsls(Y,X,phats);
    betas=reshape(beta,[length(beta)/4,4]);
else
    beta=Paramsls(Y,X,phats,beta_p);
    betas=reshape(beta,[length(beta)/4,4]);
end

end